import time
from PIL import Image
from selenium import webdriver
import dama
from selenium.webdriver.common.by import By

driver = webdriver.Edge()
driver.maximize_window()
driver.get('http://49.233.83.37:8080/jeewms/')

#用户名 userName
username=driver.find_element(By.NAME,'userName')
username.clear()
username.send_keys('admin')
#密码
password = driver.find_element(By.NAME,'password')
password.clear()
password.send_keys('yan030220@')

#验证码
da=driver.save_screenshot('dama.png')
#获取验证码图片的定位
yzm=driver.find_element(By.ID,'randCodeImage')
time.sleep(2)
locatin=yzm.location
print(locatin)
size=yzm.size
print(size)
#将验证码从大截图中截出来
left=locatin['x']
top=locatin['y']
right=left+size['width']
bottom=top+size['height']
Image=Image.open('dama.png')
Image1=Image.crop((left*1.75,top*1.75 ,right*1.75,bottom*1.75))
Image1.save('image2.png')
